<template>
  <TopTapMovie></TopTapMovie>
  <keep-alive>
    <router-view
      :key="'film' + filmlist.length"
      :list="filmlist"
      :type="1"
      @fang="requestlist"
      :thelis="thefilmllst"
    ></router-view>
  </keep-alive>
</template>

<script setup lang="ts">
import TopTapMovie from "../components/TopTapMovie.vue";
import { onMounted, ref } from "vue";
import { nowPlayingListData, comingSoonListData } from "../axios/http";
import { ListType } from "../types/index";
import { useStore } from "vuex";
const store = useStore();
const flag = ref<boolean>(true);
const indx = ref<string>("1");
// 上映电影列表
const filmlist = ref<Array<ListType>>([]);
//即将上映列表
const thefilmllst = ref<Array<ListType>>([]);
onMounted(async () => {
  requestlist();
  flag.value = false;
  thelist();
});
const requestlist = async () => {
  let arr = await nowPlayingListData(indx.value, store.state.getinfo.id);
  filmlist.value = [...filmlist.value, ...arr.data.films];
  indx.value = (parseInt(indx.value) + 1).toString();
};

const thelist = async () => {
  let arr = await comingSoonListData(indx.value);
  console.log(arr.data.films);
  thefilmllst.value = arr.data.films;
};
</script>
<style scoped lang="less"></style>
